<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class Psa_Pdo</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			
<h2 class="class-name"><img src="../media/images/Class_logo.png"
														alt=" Class"
														title=" Class"
														style="vertical-align: middle"> Psa_Pdo</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
													<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
						|											<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
						
					</div>
	<div class="info-box-body">
        		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Simple database connection class and database access wrapper class.</p>
<p class="description"><p>Handles database connection and executes queries against the database.</p><p>PSA uses <a href="http://www.php.net/pdo">PHP Data Objects (PDO)</a> extension for  database access. Methods in this class are wrappers for corresponding PDO methods.  You should also use PDO for database access in your applications  based on PSA because database connection is already open and you dont't want  to open another connection to database form another driver like mysqli.  Also you shouldn't open new PDO connection if it's not necessary, instead you  should use already open connection by PSA.</p><p>If you don't want to use this class for database connection in your model  methods, you should at least use the same connection object that can be accessed  through <kbd>$this-&gt;psa_database-&gt;connection</kbd> in model method.</p><p>See in examples below how you can access Psa_Pdo object or PDO connection object  in model methods.</p><p><strong>Examples:</strong></p><p><div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-key">class&nbsp;</span><span class="src-id">my_model&nbsp;</span><span class="src-key">extends&nbsp;</span><a href="../psa/plugins/Psa_Plugin_Model.html">Psa_Plugin_Model</a>&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;returns&nbsp;all&nbsp;records&nbsp;from&nbsp;table</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">get_all_records</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-str">&quot;SELECT&nbsp;*&nbsp;FROM&nbsp;table&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">fetch_all</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;returns&nbsp;selected&nbsp;row&nbsp;from&nbsp;table</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">get_one_row</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-str">&quot;SELECT&nbsp;*&nbsp;FROM&nbsp;table&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;123&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">fetch_row</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;iterates&nbsp;through&nbsp;each&nbsp;row</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">sum_all</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sum&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-str">&quot;SELECT&nbsp;*&nbsp;FROM&nbsp;table&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">while</span><span class="src-sym">(</span><span class="src-var">$row&nbsp;</span>=&nbsp;<span class="src-var">$database</span><span class="src-sym">-&gt;</span><span class="src-id">fetch_row</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sum&nbsp;</span>+=&nbsp;<span class="src-var">$row</span><span class="src-sym">[</span><span class="src-str">'column1'</span><span class="src-sym">]&nbsp;</span>+&nbsp;<span class="src-var">$row</span><span class="src-sym">[</span><span class="src-str">'column2'</span><span class="src-sym">]&nbsp;</span>+&nbsp;<span class="src-var">$row</span><span class="src-sym">[</span><span class="src-str">'column3'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$sum</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;executes&nbsp;prepared&nbsp;statement</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">save_values</span><span class="src-sym">(</span><span class="src-var">$value1</span><span class="src-sym">,&nbsp;</span><span class="src-var">$value2</span><span class="src-sym">,&nbsp;</span><span class="src-var">$value3</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;query</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-str">&quot;INSERT&nbsp;INTO&nbsp;table&nbsp;(column1,&nbsp;column2,&nbsp;column3)&nbsp;VALUES&nbsp;(?,?,?)&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;argument&nbsp;for&nbsp;execute()&nbsp;method</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qparams&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$value1</span><span class="src-sym">,</span><span class="src-var">$value2</span><span class="src-sym">,</span><span class="src-var">$value3</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;execute&nbsp;query</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">execute</span><span class="src-sym">(</span><span class="src-var">$qparams</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">prepare</span><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;<span class="src-sym">(</span><span class="src-id"><a href="../psa/exceptions/Psa_Db_Exception.html">Psa_Db_Exception</a>&nbsp;</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-num">0</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">last_insert_id</span><span class="src-sym">(</span><span class="src-str">'seq_name'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;use&nbsp;transactions</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">save_values2</span><span class="src-sym">(</span><span class="src-var">$value1</span><span class="src-sym">,&nbsp;</span><span class="src-var">$value2</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;start&nbsp;transaction</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;be&nbsp;sure&nbsp;to&nbsp;have&nbsp;database&nbsp;connection&nbsp;before&nbsp;beginTransaction()</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">connect</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">connection</span><span class="src-sym">-&gt;</span><span class="src-id">beginTransaction</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;queries</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql1&nbsp;</span>=&nbsp;<span class="src-str">&quot;INSERT&nbsp;INTO&nbsp;table1&nbsp;(column1)&nbsp;VALUES&nbsp;(?)&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">execute</span><span class="src-sym">(</span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$value1</span><span class="src-sym">)</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">prepare</span><span class="src-sym">(</span><span class="src-var">$sql1</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql2&nbsp;</span>=&nbsp;<span class="src-str">&quot;INSERT&nbsp;INTO&nbsp;table2&nbsp;(column2)&nbsp;VALUES&nbsp;(?)&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">execute</span><span class="src-sym">(</span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$value2</span><span class="src-sym">)</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">prepare</span><span class="src-sym">(</span><span class="src-var">$sql2</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;</div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;commit</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">psa_database</span><span class="src-sym">-&gt;</span><span class="src-id">connection</span><span class="src-sym">-&gt;</span><span class="src-id">commit</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
</ol></div></p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/_config.php.html">config.php</a></li>
			</ul>
		<p class="notes">
			Located in <a class="field" href="_scripts---Psa_Pdo.class.php.html">/scripts/Psa_Pdo.class.php</a> (line <span class="field"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a128">128</a></span>)
		</p>
		
				
		<pre></pre>
	
			</div>
</div>



	<a name="sec-var-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Variable Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
						<span class="disabled">Vars</span> (<a href="#sec-vars">details</a>)
							| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
								</div>
		<div class="info-box-body">
			<div class="var-summary">
																																																																								<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">PDO</span>
					<a href="#$connection" title="details" class="var-name">$connection</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">array</span>
					<a href="#$driver_options" title="details" class="var-name">$driver_options</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">string</span>
					<a href="#$dsn" title="details" class="var-name">$dsn</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">array</span>
					<a href="#$fetched_rows" title="details" class="var-name">$fetched_rows</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">string</span>
					<a href="#$password" title="details" class="var-name">$password</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">PDOStatement</span>
					<a href="#$result" title="details" class="var-name">$result</a>
				</div>
																<div class="var-title">
					<img src="../media/images/Variable.png" alt=" " />
					<span class="var-type">string</span>
					<a href="#$username" title="details" class="var-name">$username</a>
				</div>
											</div>
		</div>
	</div>

	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
																		<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
				 
				|
						<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">			
			<div class="method-summary">
																																																																																																<div class="method-definition">
					<img src="../media/images/Constructor.png" alt=" "/>
											<span class="method-result">Psa_Pdo</span>
										<a href="#__construct" title="details" class="method-name">__construct</a>
											([<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span> = <span class="var-default">null</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">int|boolean</span>
										<a href="#affected_rows" title="details" class="method-name">affected_rows</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">boolean</span>
										<a href="#connect" title="details" class="method-name">connect</a>
											([<span class="var-type">string</span>&nbsp;<span class="var-name">$dsn</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$username</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$driver_options</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$throw_PDOException</span> = <span class="var-default">0</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">string</span>
										<a href="#escape" title="details" class="method-name">escape</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">bool</span>
										<a href="#execute" title="details" class="method-name">execute</a>
											([<span class="var-type">array</span>&nbsp;<span class="var-name">$params</span> = <span class="var-default">null</span>], [<span class="var-type">object PDOStatement</span>&nbsp;<span class="var-name">$statement</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$throw_PDOException</span> = <span class="var-default">0</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">array</span>
										<a href="#fetch_all" title="details" class="method-name">fetch_all</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">array</span>
										<a href="#fetch_row" title="details" class="method-name">fetch_row</a>
										()
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">string</span>
										<a href="#last_insert_id" title="details" class="method-name">last_insert_id</a>
											([<span class="var-type">string</span>&nbsp;<span class="var-name">$sequence</span> = <span class="var-default">null</span>])
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">object PDOStatement</span>
										<a href="#prepare" title="details" class="method-name">prepare</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span>)
									</div>
																<div class="method-definition">
					<img src="../media/images/Method.png" alt=" "/>
											<span class="method-result">boolean</span>
										<a href="#query" title="details" class="method-name">query</a>
											(<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span>)
									</div>
											</div>
		</div>
	</div>		

	<a name="sec-vars"></a>
	<div class="info-box">
		<div class="info-box-title">Variables</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
										<a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)
						
			
										| 
									<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
							
					</div>
		<div class="info-box-body">
			
<a name="var$connection" id="$connection"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">PDO</span>
			<span class="var-name">$connection</span>
			 = <span class="var-default"> null</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a136">136</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PDO database connection object.</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodconnect">Psa_Pdo::connect()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$driver_options" id="$driver_options"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$driver_options</span>
			 = <span class="var-default">array()</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a181">181</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PDO driver options</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$dsn" id="$dsn"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$dsn</span>
			 = <span class="var-default"> null</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a166">166</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PDO data source name.</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$fetched_rows" id="$fetched_rows"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">array</span>
			<span class="var-name">$fetched_rows</span>
						(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a157">157</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Associative array with all fetched records.</p>
<p class="description"><p>It is set by <a href="../psa/Psa_Pdo.html#methodfetch_all">fetch_all()</a> method.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodfetch_all">Psa_Pdo::fetch_all()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$password" id="$password"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$password</span>
			 = <span class="var-default"> null</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a176">176</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Database password.</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$result" id="$result"><!-- --></A>
<div class="evenrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">PDOStatement</span>
			<span class="var-name">$result</span>
						(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a147">147</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Query result.</p>
<p class="description"><p>Result from <a href="../psa/Psa_Pdo.html#methodquery">query()</a> or <a href="../psa/Psa_Pdo.html#methodexecute">execute()</a> method.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodquery">Psa_Pdo::query()</a></li>
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodexecute">Psa_Pdo::execute()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
<a name="var$username" id="$username"><!-- --></A>
<div class="oddrow">

	<div class="var-header">
		<img src="../media/images/Variable.png" />
		<span class="var-title">
			<span class="var-type">string</span>
			<span class="var-name">$username</span>
			 = <span class="var-default"> null</span>			(line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a171">171</a></span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Database username.</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	
		
		

</div>
						
		</div>
	</div>
	
	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
														<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
						
		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="method__construct" id="__construct"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Constructor.png" />
		<span class="method-title">Constructor __construct</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a190">190</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">If <var>$sql</var> parameter is set query is executed against database with query() method</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodquery">Psa_Pdo::query()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">Psa_Pdo</span>
		<span class="method-name">
			__construct
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span> = <span class="var-default">null</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$sql</span><span class="var-description">: database query</span>			</li>
				</ul>
		
			
	</div>
<a name="methodaffected_rows" id="affected_rows"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">affected_rows</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a235">235</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Returns the number of rows affected by a DELETE, INSERT, or UPDATE statement.</p>
	<ul class="tags">
				<li><span class="field">return:</span> number of rows affected, false if there is no result</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">int|boolean</span>
		<span class="method-name">
			affected_rows
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodconnect" id="connect"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">connect</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a273">273</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Connects to the database.</p>
<p class="description"><p>If called without arguments it first uses connection parameters from object properties (<a href="../psa/Psa_Pdo.html#var$dsn">$dsn</a>,  <a href="../psa/Psa_Pdo.html#var$username">$username</a>, <a href="../psa/Psa_Pdo.html#var$password">$password</a>, <a href="../psa/Psa_Pdo.html#var$driver_options">$driver_options</a>) and if  <a href="../psa/Psa_Pdo.html#var$dsn">$dsn</a> value is not set takes connection parameters from <var>$PSA_CFG</var> global array  from <a href="../psa/_config.php.html">config.php</a>.  Throws a <a href="../psa/exceptions/Psa_Fatal_Error_Exception.html">Psa_Fatal_Error_Exception</a> if the attempt to connect to the requested database fails.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/_config.php.html">config.php</a></li>
				<li><span class="field">throws:</span> Psa_Fatal_Error_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">boolean</span>
		<span class="method-name">
			connect
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$dsn</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$username</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">null</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$driver_options</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$throw_PDOException</span> = <span class="var-default">0</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$dsn</span><span class="var-description">: PDO data source name</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$username</span><span class="var-description">: username</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$password</span><span class="var-description">: password</span>			</li>
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$driver_options</span><span class="var-description">: pdo driver-specific connection options</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$throw_PDOException</span><span class="var-description">: if true PDOException will be thrown instead Psa_Fatal_Error_Exception</span>			</li>
				</ul>
		
			
	</div>
<a name="methodescape" id="escape"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">escape</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a369">369</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Escapes special characters in a string for use in a SQL statement.</p>
	<ul class="tags">
				<li><span class="field">return:</span> escaped string</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			escape
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$value</span><span class="var-description">: string to escape</span>			</li>
				</ul>
		
			
	</div>
<a name="methodexecute" id="execute"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">execute</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a412">412</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Executes a prepared statement.</p>
<p class="description"><p>Throws a <a href="../psa/exceptions/Psa_Db_Exception.html">Psa_Db_Exception</a> if statement fails.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodprepare">Psa_Pdo::prepare()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">bool</span>
		<span class="method-name">
			execute
		</span>
					([<span class="var-type">array</span>&nbsp;<span class="var-name">$params</span> = <span class="var-default">null</span>], [<span class="var-type">object PDOStatement</span>&nbsp;<span class="var-name">$statement</span> = <span class="var-default">null</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$throw_PDOException</span> = <span class="var-default">0</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">array</span>
				<span class="var-name">$params</span><span class="var-description">: an array of values with as many elements as there are bound  parameters in the SQL statement being executed</span>			</li>
					<li>
				<span class="var-type">object PDOStatement</span>
				<span class="var-name">$statement</span><span class="var-description">: if not set <a href="../psa/Psa_Pdo.html#var$result">$result</a> is used</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$throw_PDOException</span><span class="var-description">: if true PDOException will be thrown instead Psa_Db_Exception</span>			</li>
				</ul>
		
			
	</div>
<a name="methodfetch_all" id="fetch_all"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">fetch_all</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a337">337</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Returns all rows from result.</p>
<p class="description"><p>And fills <a href="../psa/Psa_Pdo.html#var$fetched_rows">$fetched_rows</a> member associative array.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> associative array with all records from result of last query.</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#var$fetched_rows">Psa_Pdo::$fetched_rows</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">array</span>
		<span class="method-name">
			fetch_all
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodfetch_row" id="fetch_row"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">fetch_row</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a352">352</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Fetch next row from result.</p>
	<ul class="tags">
				<li><span class="field">return:</span> associative array. A row from result.</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">array</span>
		<span class="method-name">
			fetch_row
		</span>
				()
			</div>
	
		
			
	</div>
<a name="methodlast_insert_id" id="last_insert_id"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">last_insert_id</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a250">250</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Returns the ID of the last inserted row</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			last_insert_id
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$sequence</span> = <span class="var-default">null</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$sequence</span><span class="var-description">: sequence name</span>			</li>
				</ul>
		
			
	</div>
<a name="methodprepare" id="prepare"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">prepare</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a388">388</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Prepares a statement for execution.</p>
<p class="description"><p>Returns a statement object and also sets <a href="../psa/Psa_Pdo.html#var$result">$result</a> member object.</p></p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../psa/Psa_Pdo.html#methodexecute">Psa_Pdo::execute()</a></li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">object PDOStatement</span>
		<span class="method-name">
			prepare
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$sql</span>			</li>
				</ul>
		
			
	</div>
<a name="methodquery" id="query"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<img src="../media/images/Method.png" />
		<span class="method-title">query</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsPsa_Pdo.class.php.html#a204">204</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Performs a query against the database.</p>
<p class="description"><p>Throws a <a href="../psa/exceptions/Psa_Db_Exception.html">Psa_Db_Exception</a> if query fails.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> true if success</li>
				<li><span class="field">throws:</span> Psa_Db_Exception</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">boolean</span>
		<span class="method-name">
			query
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$sql</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$sql</span><span class="var-description">: database query</span>			</li>
				</ul>
		
			
	</div>
						
		</div>
	</div>

	
	<p class="notes" id="credit">
		Documentation generated on Thu, 21 Oct 2010 01:40:52 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
	</p>
	</div></body>
</html>